<template>
  <el-cascader
    size="small"
    :value="value"
    :options="getRootGroup"
    :placeholder="configData.placeholder"
    @change="onchange"
  />
</template>
<script>
import { commonData } from '@/utils/cache'

export default {
  name: 'RootGroup',
  props: ['configData', 'value'],
  data() {
    return {
    }
  },
  computed: {
    getRootGroup: function() {
      return commonData.getRootGroup
    }
  },
  watch: {
    'getRootGroup': function() {
      this.getRootGroup.map(item => {
        this.replace(item)
        return item
      })
    }
  },
  created() {
  },
  methods: {
    replace(obj) {
      obj.value = obj.type
      obj.label = obj.typeName
      obj.children = obj.rootGroupList
      if (obj.children) {
        obj.rootGroupList.map(item => {
          item.value = item.rootGroupId
          item.label = item.name
          return item
        })
      }
    },
    onchange(e) {
      console.log(e, 'change数据')
      this.$emit('change', e)
    }
  }
}
</script>

<style scoped>

</style>
